package com.njsoft.huanxin;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.util.MultiTypeDelegate;
import java.util.List;

public class MultiImageAdapter extends BaseQuickAdapter<MsgBean, BaseViewHolder> {
    private Context context;

    public MultiImageAdapter(Context context, List<MsgBean> list) {
        super(list);
        this.context = context;
        //Step.1
        setMultiTypeDelegate(new MultiTypeDelegate<MsgBean>() {
            @Override
            protected int getItemType(MsgBean entity) {
                //根据你的实体类来判断布局类型
                return entity.getItemType();
            }
        });
        //Step.2
        getMultiTypeDelegate()
                .registerItemType(MsgBean.MsgSend, R.layout.msg_send)
                .registerItemType(MsgBean.MsgReceicer, R.layout.msg_receiver);
    }

    @Override
    protected void convert(BaseViewHolder helper, MsgBean entity) {
        //Step.3
        switch (helper.getItemViewType()) {
            case MsgBean.MsgSend:
                // do something
                 helper.setText(R.id.ChatMsgSender,entity.getContent());
                break;
            case MsgBean.MsgReceicer:
                // do something
                helper.setText(R.id.ChatMsgRecevier,entity.getContent());

                break;
        }
    }
}